/**
 * Created by Administrator on 2017/10/19.
 */
function Page(container, callback, opts)
{
	baidu.lang.Class.call(this);
	if (!container)
	{
		return;
	}
	this.container = typeof container == "object" ? container : baidu.G(container);
	this.page = 1;
	this.pageCount = 100;
	this.argName = "pg";
	this.pagecap = 4;
	this.callback = callback;
	this.update = true;
	var _config = {page: 1, totalCount: 100, pageCount: 100, pagecap: 4, argName: "pg", update: true};
	if (!opts)
	{
		opts = _config;
	}
	for (var p in opts)
	{
		if (typeof opts[p] != "undefined")
		{
			this[p] = opts[p];
		}
	}
	this.render()
}
baidu[Textend](Page[Tprototype], {
	render: function ()
	{
		this.initialize()
	}, initialize: function ()
	{
		this.checkPages();
		this.container.innerHTML = this.createHtml()
	}, checkPages: function ()
	{
		if (isNaN(TparseInt(this.page)))
		{
			this.page = 1;
		}
		if (isNaN(TparseInt(this.pageCount)))
		{
			this.pageCount = 1;
		}
		if (this.page < 1)
		{
			this.page = 1;
		}
		if (this.pageCount < 1)
		{
			this.pageCount = 1;
		}
		if (this.page > this.pageCount)
		{
			this.page = this.pageCount;
		}
		this.page = TparseInt(this.page);
		this.pageCount = TparseInt(this.pageCount)
	}, getPage: function ()
	{
		var args = location.search;
		var reg = new TRegExp("[?&]?" + this.argName + "=([^&]*)[&$]?", "gi");
		var chk = args.match(reg);
		this.page = TRegExp.$1
	}, createHtml: function ()
	{
		var strHtml = [], prevPage = this.page - 1, nextPage = this.page + 1;
		strHtml.push('<p style="margin:0;padding:0;white-space:nowrap">');
		if (prevPage < 1)
		{
			;
		}
		else
		{
			if (this.page >= this.pagecap)
			{
				var html = '<span style="margin-right:3px"><a style="color:#7777cc" href="javascript:void(0)" onclick="{temp1}">\u9996\u9875</a></span>';
				strHtml.push(html.replace("{temp1}", "BMap.I('" + this.guid + "').toPage(1);"))
			}
			var html = '<span style="margin-right:3px"><a style="color:#7777cc" href="javascript:void(0)" onclick="{temp2}">\u4e0a\u4e00\u9875</a></span>';
			strHtml.push(html.replace("{temp2}", "BMap.I('" + this.guid + "').toPage(" + prevPage + ");"))
		}
		if (this.page < this.pagecap)
		{
			if (this.page % this.pagecap == 0)
			{
				var startPage = this.page - this.pagecap - 1;
			}
			else
			{
				var startPage = this.page - this.page % this.pagecap + 1;
			}
			var endPage = startPage + this.pagecap - 1
		}
		else
		{
			var spt = TMath.floor(this.pagecap / 2);
			var mod = this.pagecap % 2 - 1;
			if (this.pageCount > this.page + spt)
			{
				var endPage = this.page + spt;
				var startPage = this.page - spt - mod
			}
			else
			{
				var endPage = this.pageCount;
				var startPage = this.page - spt - mod
			}
		}
		if (this.page > this.pageCount - this.pagecap && this.page >= this.pagecap)
		{
			var startPage = this.pageCount - this.pagecap + 1;
			var endPage = this.pageCount
		}
		for (var i = startPage; i <= endPage; i++)
		{
			if (i > 0)
			{
				if (i == this.page)
				{
					strHtml.push('<span style="margin-right:3px">' + i + "</span>");
				}
				else if (i >= 1 && i <= this.pageCount)
				{
					var html = '<span><a style="color:#7777cc;margin-right:3px" href="javascript:void(0)" onclick="{temp3}">[' + i + "]</a></span>";
					strHtml.push(html.replace("{temp3}", "BMap.I('" + this.guid + "').toPage(" + i + ");"))
				}
			}
		}
		if (nextPage > this.pageCount)
		{
			;
		}
		else
		{
			var html = '<span><a style="color:#7777cc" href="javascript:void(0)" onclick="{temp4}">\u4e0b\u4e00\u9875</a></span>';
			strHtml.push(html.replace("{temp4}", "BMap.I('" + this.guid + "').toPage(" + nextPage + ");"))
		}
		strHtml.push("</p>");
		return strHtml.join("")
	}, "toPage": function (page)
	{
		var turnTo = page ? page : 1;
		if (typeof this.callback == "function")
		{
			this.callback(turnTo);
			this.page = turnTo
		}
		if (this.update)
		{
			this.render()
		}
	}
});
LocalSearch.isReqDataMap = function (qt, type)
{
	if (!qt || typeof type == "undefined")
	{
		return false;
	}
	if (qt == QUERY_TYPE_POI_SEARCH && type != RETURN_TYPE_POI_SEARCH && type != RETURN_TYPE_CITY_LIST && type != RETURN_TYPE_CURRENT_CITY && type != RETURN_TYPE_SPECIAL_REGION && type != RETURN_TYPE_NODATA_REGION)
	{
		return false;
	}
	if (qt == QUERY_TYPE_SEARCH_NEARBY && type != RETURN_TYPE_SEARCH_NEARBY)
	{
		return false;
	}
	if (qt == QUERY_TYPE_SEARCH_INBOUNDS && type != RETURN_TYPE_SEARCH_INBOUNDS)
	{
		return false;
	}
	if (qt == QUERY_TYPE_SEARCH_INBOUNDS_MULTIKEY && type != RETURN_TYPE_SEARCH_INBOUNDS_MULTIKEY)
	{
		return false;
	}
	if (qt == QUERY_TYPE_SEARCH_MULTIKEY && type != RETURN_TYPE_SEARCH_MULTIKEY)
	{
		return false;
	}
	if (qt == QUERY_TYPE_SEARCH_NEARBY_MULTIKEY && type != RETURN_TYPE_SEARCH_NEARBY_MULTIKEY)
	{
		return false;
	}
	return true
};
baidu[Textend](LocalSearch[Tprototype], {
	_check: function ()
	{
		for (var i = 0, l = this._queryList[Tlength]; i < l; i++)
		{
			var q = this._queryList[i];
			this[q.method].apply(this, q.arguments)
		}
		delete this._queryList;
		this.initialize()
	}, initialize: function ()
	{
		var me = this;
		this.renderMap = new RenderMap(me);
		this.renderList = new RenderList(me)
	}, search: function (keyword, options)
	{
		if (!keyword || keyword instanceof Array && (keyword[Tlength] < 1 || keyword[Tlength] > 10))
		{
			this.clearResults();
			this._setStatus(BMAP_STATUS_INVALID_REQUEST);
			this._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE);
			return
		}
		options = options || {};
		if (options["customData"])
		{
			this._createCustomSearchInstance();
			this.customSearch.search({keyword: keyword, customData: options["customData"]});
			this._useCustomdata = true;
			return
		}
		else
		{
			this._useCustomdata = false;
		}
		var opts = arguments[2] || {};
		var me = this;
		this._getIdByLoc(this._loc, function (id)
		{
			id = id || 1;
			me._isMultiKey = me._isKeywordArray(keyword);
			var _opts;
			if (!me._isMultiKey)
			{
				_opts = {
					"qt": options["forceLocal"] ? QUERY_TYPE_POI_SEARCH_CON : QUERY_TYPE_POI_SEARCH,
					"c": id,
					"wd": keyword,
					"rn": me.getPageCapacity()
				};
			}
			else
			{
				var wds = keyword.join("$$");
				var wdsn = keyword[Tlength];
				_opts = {"qt": QUERY_TYPE_SEARCH_MULTIKEY, "c": id, "wd": wds, "wdn": wdsn, "rn": me.getPageCapacity()}
			}
			if (me._opts.reqFrom)
			{
				baidu[Textend](_opts, {"from": me._opts.reqFrom});
			}
			baidu[Textend](_opts, opts.params);
			if (options.log)
			{
				_opts["log"] = "center";
			}
			var ud = {params: _opts, options: options, userKw: opts.userKw || keyword};
			baidu[Textend](ud, opts);
			SearchRequestMgr.request(function (json, userData)
			{
				me._rawDataCbk(json, userData)
			}, _opts, ud)
		})
	}, _isKeywordArray: function (keyword)
	{
		if (keyword && keyword instanceof Array)
		{
			return true;
		}
		else
		{
			return false
		}
	}, searchInBounds: function (keyword, bounds, options)
	{
		if (!keyword || !bounds || keyword instanceof Array && (keyword[Tlength] < 1 || keyword[Tlength] > 10))
		{
			this.clearResults();
			this._setStatus(BMAP_STATUS_INVALID_REQUEST);
			this._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE);
			return
		}
		var options = options || {};
		var me = this;
		if (options["customData"])
		{
			this._createCustomSearchInstance();
			this.customSearch.search({keyword: keyword, bounds: bounds, customData: options["customData"]});
			this._useCustomdata = true;
			return
		}
		else
		{
			this._useCustomdata = false;
		}
		var opts = arguments[2] || {};
		this._getIdByLoc(this._loc, function (id)
		{
			id = id || 1;
			var pt1 = bounds.getSouthWest();
			var pt2 = bounds.getNorthEast();
			pt1 = MercatorProjection.convertLL2MC(pt1);
			pt2 = MercatorProjection.convertLL2MC(pt2);
			var bdstr = "(" + pt1["lng"] + "," + pt1["lat"] + ";" + pt2["lng"] + "," + pt2["lat"] + ")";
			me._isMultiKey = me._isKeywordArray(keyword);
			var _opts;
			if (!me._isMultiKey)
			{
				_opts = {
					"qt": QUERY_TYPE_SEARCH_INBOUNDS,
					"c": id,
					"wd": keyword,
					"ar": bdstr,
					"rn": me._opts.pageCapacity,
					"l": 18
				};
			}
			else
			{
				var wds = keyword.join("$$");
				var wdsn = keyword[Tlength];
				_opts = {
					"qt": QUERY_TYPE_SEARCH_INBOUNDS_MULTIKEY,
					"c": id,
					"wd": wds,
					"wdn": wdsn,
					"ar": bdstr,
					"rn": me.getPageCapacity(),
					"l": 18
				}
			}
			if (me._opts.reqFrom)
			{
				baidu[Textend](_opts, {"from": me._opts.reqFrom});
			}
			baidu[Textend](_opts, opts.params);
			var ud;
			if (opts && opts.center && opts.radius)
			{
				ud = {
					params: _opts,
					bounds: bounds,
					center: opts.center,
					radius: opts.radius,
					userKw: opts.userKw || keyword
				};
			}
			else
			{
				ud = {params: _opts, bounds: bounds, userKw: opts.userKw || keyword};
			}
			SearchRequestMgr.request(function (json, userData)
			{
				me._rawDataCbk(json, userData)
			}, _opts, ud)
		})
	}, searchNearby: function (keyword, center, radius, options)
	{
		if (!keyword || !center || !(center instanceof Point) && typeof center == "object" && !center.uid || keyword instanceof Array && (keyword[Tlength] < 1 || keyword[Tlength] > 10))
		{
			this.clearResults();
			this._setStatus(BMAP_STATUS_INVALID_REQUEST);
			this._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE);
			return
		}
		var options = options || {};
		if (options["customData"])
		{
			this._createCustomSearchInstance();
			this.customSearch.search({
				keyword: keyword,
				center: center,
				radius: radius,
				customData: options["customData"]
			});
			this._useCustomdata = true;
			return
		}
		else
		{
			this._useCustomdata = false;
		}
		radius = radius || LocalSearch.DEFAULT_RADIUS;
		radius = radius < 0 ? LocalSearch.DEFAULT_RADIUS : radius > LocalSearch.MAX_RADIUS ? LocalSearch.MAX_RADIUS : radius;
		var me = this;
		var opts = arguments[3] || {};
		if (center instanceof Point)
		{
			var prjCenter = MercatorProjection.convertLL2MC(center);
			var prjPt1 = new Point(prjCenter["lng"] - radius, prjCenter["lat"] - radius);
			var prjPt2 = new Point(prjCenter["lng"] + radius, prjCenter["lat"] + radius);
			var pt1 = MercatorProjection.convertMC2LL(prjPt1);
			var pt2 = MercatorProjection.convertMC2LL(prjPt2);
			var bounds = new Bounds(new Point(pt1["lng"], pt1["lat"]), new Point(pt2["lng"], pt2["lat"]));
			opts.center = center;
			opts.radius = radius;
			this.searchInBounds(keyword, bounds, opts);
			return
		}
		this._getIdByLoc(this._loc, function (id)
		{
			id = id || 1;
			me._isMultiKey = me._isKeywordArray(keyword);
			var _opts;
			if (!me._isMultiKey)
			{
				_opts = {
					"qt": QUERY_TYPE_SEARCH_NEARBY,
					"c": id,
					"wd": keyword,
					"rn": me.getPageCapacity(),
					"uid": center.uid,
					"r": radius
				};
			}
			else
			{
				_opts = {
					"qt": QUERY_TYPE_SEARCH_NEARBY_MULTIKEY,
					"c": id,
					"wd": keyword.join("$$"),
					"wdn": keyword[Tlength],
					"rn": me.getPageCapacity(),
					"uid": center.uid,
					"r": radius
				};
			}
			if (typeof center == "string")
			{
				if (!me._isMultiKey)
				{
					_opts["qt"] = QUERY_TYPE_POI_SEARCH;
					_opts["wd"] = center + " " + keyword
				}
				else
				{
					_opts["qt"] = QUERY_TYPE_SEARCH_MULTIKEY;
					var nkws = [];
					for (var i = 0; i < keyword[Tlength]; i++)
					{
						var str = center + " " + keyword[i];
						nkws.push(str)
					}
					_opts["wd"] = nkws.join("$$");
					_opts["wdn"] = nkws[Tlength]
				}
				delete _opts["r"];
				delete _opts["uid"]
			}
			if (me._opts.reqFrom)
			{
				baidu[Textend](_opts, {"from": me._opts.reqFrom});
			}
			baidu[Textend](_opts, opts.params);
			SearchRequestMgr.request(function (json, userData)
			{
				me._rawDataCbk(json, userData)
			}, _opts, {params: _opts, center: center, radius: radius, userKw: opts.userKw || keyword})
		})
	}, _rawDataCbk: function (json, userData)
	{
		var me = this;
		if (json["result"]["type"] == RETURN_TYPE_SEARCH_INBOUNDS_MULTIKEY || json["result"]["type"] == RETURN_TYPE_SEARCH_MULTIKEY || json["result"]["type"] == RETURN_TYPE_SEARCH_NEARBY_MULTIKEY)
		{
			me._isMultiKey = true;
		}
		else
		{
			me._isMultiKey = false;
		}
		this.clearResults();
		me._json = json;
		this._ud = userData;
		var r = json["result"];
		var qt = userData.params["qt"];
		if (!me._isMultiKey)
		{
			if (r["error"] != 0 || !LocalSearch.isReqDataMap(qt, r["type"]))
			{
				var cc = json["current_city"];
				this._results = new LocalResult({
					keyword: userData.userKw,
					city: cc["name"],
					province: cc["up_province_name"] || "",
					ccode: cc["code"],
					pc: me.getPageCapacity(),
					center: userData.center,
					radius: userData.radius,
					bounds: userData.center && userData.radius ? undefined : userData.bounds,
					moreUrl: this._getMoreUrl(userData, cc)
				});
				this._results._qt = userData.params["qt"];
				this._setStatus(BMAP_STATUS_UNKNOWN_LOCATION);
				this._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE, this._results);
				me.renderList.dispatchEvent("render");
				return
			}
		}
		else if (r["error"] != 0 || !LocalSearch.isReqDataMap(qt, r["type"]))
		{
			var cc = json["current_city"];
			this._arrResults = [];
			var wds = userData.userKw;
			for (var i = 0, l = wds[Tlength]; i < l; i++)
			{
				var results = new LocalResult({
					keyword: wds[i],
					city: cc["name"],
					province: cc["up_province_name"] || "",
					ccode: cc["code"],
					pc: me.getPageCapacity(),
					center: userData.center,
					radius: userData.radius,
					bounds: userData.center && userData.radius ? undefined : userData.bounds,
					moreUrl: ""
				});
				results._qt = userData.params["qt"];
				this._arrResults.push(results)
			}
			this._setStatus(BMAP_STATUS_UNKNOWN_LOCATION);
			this._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE, this._arrResults);
			me.renderList.dispatchEvent("render");
			return
		}
		me._processRaw(userData);
		me.renderMap.dispatchEvent("render");
		me.renderList.dispatchEvent("render");
		var center = this._ud.center;
		if (center && typeof center != "string" && !(center instanceof Point))
		{
			this.renderMap.addCenterPoi(center);
		}
		var type = this._json.result && this._json.result.type;
		var viewData = {};
		switch (type)
		{
			case RETURN_TYPE_POI_SEARCH:
			case RETURN_TYPE_SEARCH_NEARBY:
			case RETURN_TYPE_SEARCH_INBOUNDS:
			case RETURN_TYPE_SEARCH_INBOUNDS_MULTIKEY:
			case RETURN_TYPE_SEARCH_MULTIKEY:
			case RETURN_TYPE_SEARCH_NEARBY_MULTIKEY:
				viewData.points = this._arrPoints;
				break;
			case RETURN_TYPE_CURRENT_CITY:
				viewData.center = this._results.getPoi(0)["point"];
				viewData.level = this._json["content"]["level"];
				break;
			case RETURN_TYPE_NODATA_REGION:
				viewData.center = this._results.getPoi(0)["point"];
				viewData.level = 13;
				break;
			case RETURN_TYPE_SPECIAL_REGION:
				viewData.center = this._results.getPoi(0)["point"];
				viewData.level = TparseInt(this._json["content"][1]);
				break;
			default:
				break
		}
		this.renderMap.getBestViewport(viewData);
		var rs;
		if (!this._isMultiKey)
		{
			rs = this._results;
		}
		else
		{
			rs = this._getMaxResults();
		}
		if (this._opts.renderOptions.selectFirstResult && rs && rs.getNumPois() > 0)
		{
			var me = this;
			setTimeout(function ()
			{
				me.select(0)
			}, 240)
		}
	}, _processRaw: function (userData)
	{
		var r = this._json["result"], c = this._json["content"], cc = this._json["current_city"], type = r["type"], me = this, pageNum = r["page_num"] || 0, total = 0, count = 0, results = [], points = [], cityList = [], arrResults = [], arrParam = [], suggestions = [];
		if (this._json["psrs"] && this._json["psrs"]["SEResult"])
		{
			var seResult = this._json["psrs"]["SEResult"];
			if (seResult["length"] > 0)
			{
				for (var i = 0, len = seResult["length"]; i < len; ++i)
				{
					suggestions.push(seResult[i])
				}
			}
		}
		var sugs = this._json["suggest_query"];
		if (sugs)
		{
			for (var i = 0, len = sugs["length"]; i < len; ++i)
			{
				sugs[i] && sugs[i]["query"] && suggestions.push(sugs[i]["query"]);
			}
		}
		suggestions = SUtil.unique(suggestions);
		if (type != RETURN_TYPE_CITY_LIST && type != RETURN_TYPE_SPECIAL_REGION)
		{
			var start;
			if (!this._isMultiKey)
			{
				count = r["count"] - (pageNum == 0 ? r["spec_dispnum"] || 0 : 0);
				total = r["total"] < 760 ? r["total"] : 760;
				start = pageNum == 0 ? r["spec_dispnum"] || 0 : 0
			}
			if (type != RETURN_TYPE_CURRENT_CITY)
			{
				if (!this._isMultiKey)
				{
					for (var i = start; i < r["count"]; i++)
					{
						if (c && c[i])
						{
							var cur = c[i];
							var addr = this._formatAddr(cur["addr"], cur["poiType"]);
							var tags = [];
							if (cur["cla"] && cur["cla"]["length"] > 0)
							{
								var tagLength = cur["cla"]["length"];
								while (tagLength--)
								{
									var currentTag = cur["cla"][tagLength][1];
									currentTag = currentTag.replace("<b>", "").replace("</b>", "");
									tags.unshift(currentTag)
								}
							}
							var poi = {
								"title": cur["name"],
								"uid": cur["uid"],
								"point": SUtil.parseGeo(cur["geo"], true).point,
								"url": BaseSearch._getPoiUrl(cur["uid"], cc["code"]),
								"address": addr,
								"city": cc["name"],
								"province": cc["up_province_name"] || "",
								"phoneNumber": cur["tel"],
								"postcode": cur["zip"],
								"type": cur["poiType"] || BMAP_POI_TYPE_NORMAL,
								"isAccurate": cur["acc_flag"] && cur["acc_flag"] == 1 ? true : false
							};
							if (tags[Tlength] > 0)
							{
								poi["tags"] = tags;
							}
							results.push(poi);
							points.push(poi["point"]);
							this._arrPois.push(poi)
						}
					}
				}
				else
				{
					var resultArr = r["result_array"];
					var n = userData.userKw[Tlength];
					for (var i = 0; i < n; i++)
					{
						arrResults[i] = [];
						arrParam[i] = [];
						cityList[i] = [];
						if (!resultArr[i])
						{
							continue;
						}
						if (resultArr[i]["type"] == RETURN_TYPE_CITY_LIST)
						{
							if (c && c[i])
							{
								for (var j = 0; j < c[i][Tlength]; j++)
								{
									var cityListItem = c[i][j];
									cityList[i].push({
										"city": cityListItem["name"],
										_code: cityListItem["code"],
										"numResults": cityListItem["num"]
									})
								}
							}
							if (this._json["more_city"] && this._json["more_city"][i])
							{
								var mc = this._json["more_city"][i];
								for (var j = 0, l = mc["length"]; j < l; j++)
								{
									for (var k = 0, ll = mc[j]["city"]["length"]; k < ll; k++)
									{
										var cityListItem = mc[j]["city"][k];
										cityList[i].push({
											"city": cityListItem["name"],
											_code: cityListItem["code"],
											"numResults": cityListItem["num"]
										})
									}
								}
							}
							continue
						}
						var ct = resultArr[i]["count"];
						var pn = resultArr[i]["page_num"] || 0;
						var tt = resultArr[i]["total"] > 760 ? 760 : resultArr[i]["total"];
						var param = {count: ct, pagenum: pn, total: tt};
						arrParam[i].push(param);
						for (var j = 0; j < ct; j++)
						{
							if (c && c[i] && c[i][j])
							{
								var cur = c[i][j];
								var addr = this._formatAddr(cur["addr"], cur["poiType"]);
								var tags = [];
								if (cur["cla"] && cur["cla"]["length"] > 0)
								{
									var tagLength = cur["cla"]["length"];
									while (tagLength--)
									{
										var currentTag = cur["cla"][tagLength][1];
										currentTag = currentTag.replace("<b>", "").replace("</b>", "");
										tags.unshift(currentTag)
									}
								}
								var poi = {
									"title": cur["name"],
									"uid": cur["uid"],
									"point": SUtil.parseGeo(cur["geo"], true).point,
									"url": BaseSearch._getPoiUrl(cur["uid"], cc["code"]),
									"address": addr,
									"city": cc["name"],
									"province": cc["up_province_name"] || "",
									"phoneNumber": cur["tel"],
									"postcode": cur["zip"],
									"type": cur["poiType"] || BMAP_POI_TYPE_NORMAL,
									"isAccurate": cur["acc_flag"] && cur["acc_flag"] == 1 ? true : false,
									"tags": tags
								};
								arrResults[i].push(poi);
								points.push(poi["point"]);
								this._arrPois.push(poi)
							}
						}
					}
				}
			}
			else
			{
				count = total = 1;
				var poi = {
					"title": c["cname"],
					"uid": c["uid"],
					"point": SUtil.parseGeo(c["geo"], true).point,
					"address": c["cname"],
					"url": MAP_URL + "?s=" + encodeURIComponent("s&wd=" + r["wd"])
				};
				results.push(poi);
				this._arrPois.push(poi);
				points.push(poi["point"])
			}
		}
		else
		{
			if (type == RETURN_TYPE_SPECIAL_REGION)
			{
				count = total = 1;
				var poi = {
					"title": r["wd"],
					"point": SUtil.parseGeoStr(c[0]),
					"url": MAP_URL + "?s=" + encodeURIComponent("s&wd=" + r["wd"])
				};
				results.push(poi);
				this._arrPois.push(poi);
				points.push(poi["point"])
			}
			if (type == RETURN_TYPE_CITY_LIST)
			{
				count = total = 0;
				for (var i = 0; i < c["length"]; i++)
				{
					cityList.push({
						"city": c[i]["name"],
						_code: c[i]["code"],
						"numResults": c[i]["num"]
					});
				}
				if (this._json["more_city"])
				{
					var mc = this._json["more_city"];
					for (var i = 0, l = mc["length"]; i < l; i++)
					{
						for (var j = 0, ll = mc[i]["city"]["length"]; j < ll; j++)
						{
							var c = mc[i].city[j];
							cityList.push({"city": c["name"], _code: c["code"], "numResults": c["num"]})
						}
					}
				}
			}
		}
		this._arrPoints = points;
		if (!this._isMultiKey)
		{
			this._results = new LocalResult({
				keyword: userData.userKw,
				count: count,
				total: total,
				pageIdx: r["page_num"],
				city: cc["name"],
				province: cc["up_province_name"] || "",
				ccode: cc["code"],
				pois: results,
				cityList: cityList,
				pc: me.getPageCapacity(),
				center: userData.center,
				radius: userData.radius,
				bounds: userData.center && userData.radius ? undefined : userData.bounds,
				moreUrl: this._getMoreUrl(userData, cc),
				suggestions: suggestions
			});
			this._results._qt = userData.params["qt"];
			if (total == 0 && type != RETURN_TYPE_CITY_LIST)
			{
				this._setStatus(BMAP_STATUS_UNKNOWN_LOCATION);
			}
			else if (type != RETURN_TYPE_CITY_LIST)
			{
				this._setStatus(BMAP_STATUS_SUCCESS);
			}
			else
			{
				this._setStatus(BMAP_STATUS_CITY_LIST);
			}
			this._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE, this._results)
		}
		else
		{
			this._arrResults = [];
			var n = userData.userKw[Tlength];
			var isTotalZero = true;
			for (var i = 0; i < n; i++)
			{
				if (arrParam[i][Tlength] > 0 && arrParam[i][0].total > 0)
				{
					isTotalZero = false;
				}
				var results = new LocalResult({
					keyword: userData.userKw[i] || "",
					count: arrParam[i][Tlength] > 0 ? arrParam[i][0].count : 0,
					total: arrParam[i][Tlength] > 0 ? arrParam[i][0].total : 0,
					pageIdx: arrParam[i][Tlength] > 0 ? arrParam[i][0].pagenum : 0,
					city: cc["name"],
					province: cc["up_province_name"] || "",
					ccode: cc["code"],
					pois: arrResults[i] || [],
					cityList: cityList[i] || [],
					pc: me.getPageCapacity(),
					center: userData.center,
					radius: userData.radius,
					bounds: userData.center && userData.radius ? undefined : userData.bounds,
					moreUrl: "",
					suggestions: suggestions
				});
				results._qt = userData.params["qt"];
				this._arrResults.push(results)
			}
			if (isTotalZero)
			{
				this._setStatus(BMAP_STATUS_UNKNOWN_LOCATION);
			}
			else
			{
				this._setStatus(BMAP_STATUS_SUCCESS);
			}
			this._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE, this._arrResults)
		}
	}, _getMoreUrl: function (userData, cc)
	{
		var retStr = "";
		var keyword = typeof userData.center == "string" ? userData.center + " " + userData.userKw : userData.userKw;
		var region = cc["name"], radius, location, bounds, param = "";
		if (typeof userData.center == "object" && !(userData.center instanceof Point))
		{
			location = userData.center["point"];
			radius = userData.radius
		}
		if (userData.bounds && !userData.center)
		{
			bounds = userData.bounds;
		}
		if (userData.center && userData.center instanceof Point)
		{
			location = userData.center;
			radius = userData.radius
		}
		retStr = API_URL + "place/search?res=jsapi&query=" + keyword + "&region=" + region + "&output=html";
		if (location)
		{
			retStr += "&location=" + location["lat"] + "," + location["lng"] + "&radius=" + radius;
		}
		if (bounds)
		{
			var sw = bounds.getSouthWest();
			var ne = bounds.getNorthEast();
			retStr += "&bounds=" + sw["lat"] + "," + sw["lng"] + "," + ne["lat"] + "," + ne["lng"]
		}
		return retStr
	}, _formatAddr: function (addr, poiType)
	{
		poiType = poiType || BMAP_POI_TYPE_NORMAL;
		if (poiType == BMAP_POI_TYPE_BUSSTOP || poiType == BMAP_POI_TYPE_SUBSTOP)
		{
			return SUtil.unique(addr.split(";")).join("; ");
		}
		return addr
	}, _chkMultiKeyResults: function (multiKeyResults)
	{
		for (var i = 0, l = multiKeyResults[Tlength]; i < l; i++)
		{
			var rs = multiKeyResults[i];
			if (rs.getCurrentNumPois() > 0)
			{
				return true
			}
		}
		return false
	}, _clearOverlays: function ()
	{
		for (var i = 0, l = this._overlays[Tlength]; i < l; i++)
		{
			this._overlays[i].remove();
			this._overlays[i] = null
		}
		this._overlays[Tlength] = 0;
		for (var i = 0, l = this._arrPois[Tlength]; i < l; i++)
		{
			this._arrPois[i] = null;
		}
		this._arrPois[Tlength] = 0;
		if (this._centerMkr)
		{
			this._centerMkr.remove();
			this._centerMkr = null
		}
	}, _getMaxResults: function ()
	{
		if (!this._isMultiKey)
		{
			return this._results;
		}
		var maxRs, minPages = -1;
		for (var i = 0, l = this._arrResults[Tlength]; i < l; i++)
		{
			var rs = this._arrResults[i];
			if (rs.getNumPages() > minPages)
			{
				maxRs = rs;
				minPages = rs.getNumPages()
			}
		}
		return maxRs
	}, clearResults: function ()
	{
		delete this._json;
		delete this._status;
		delete this._results;
		if (this._isMultiKey)
		{
			delete this._arrResults;
		}
		delete this._ud;
		this._curIndex = -1;
		this._setStatus();
		this._clearOverlays();
		if (this._opts.renderOptions.panel)
		{
			this._opts.renderOptions.panel.innerHTML = ""
		}
	}, gotoPage: function (pageNum)
	{
		if (this._useCustomdata)
		{
			this.customSearch.gotoPage(pageNum);
			return
		}
		if (this._ud)
		{
			var rs;
			if (!this._isMultiKey)
			{
				rs = this._results;
			}
			else
			{
				rs = this._getMaxResults();
			}
			if (typeof pageNum == "number" && !isNaN(pageNum) && pageNum >= 0 && pageNum <= rs.getNumPages() - 1)
			{
				this._ud.params["pn"] = pageNum;
				var qt = this._ud.params["qt"];
				switch (qt)
				{
					case QUERY_TYPE_POI_SEARCH:
					case QUERY_TYPE_POI_SEARCH_CON:
						this.search(this._ud.params["wd"], this._ud.options, this._ud);
						break;
					case QUERY_TYPE_SEARCH_INBOUNDS:
						this.searchInBounds(this._ud.params["wd"], this._ud.bounds, this._ud);
						break;
					case QUERY_TYPE_SEARCH_NEARBY:
						this.searchNearby(this._ud.params["wd"], this._ud.center, this._ud.radius, this._ud);
						break;
					case QUERY_TYPE_SEARCH_INBOUNDS_MULTIKEY:
						this.searchInBounds(this._ud.userKw, this._ud.bounds, this._ud);
						break;
					case QUERY_TYPE_SEARCH_MULTIKEY:
						this.search(this._ud.userKw, this._ud.options, this._ud);
						break;
					case QUERY_TYPE_SEARCH_NEARBY_MULTIKEY:
						this.searchNearby(this._ud.userKw, this._ud.center, this._ud.radius, this._ud);
						break;
					default:
						break
				}
			}
			else
			{
				this._setStatus(BMAP_STATUS_INVALID_REQUEST);
				this._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE)
			}
		}
	}, _createCustomSearchInstance: function ()
	{
		if (!this.customSearch)
		{
			var me = this;
			this.customSearch = new CustomSearch(me)
		}
	}, select: function (index)
	{
		this.renderMap.select(index);
		this.renderList.select(index);
		this._curIndex = index
	}
});
exportSymbol(LocalSearchP, {
	"gotoPage": LocalSearchP.gotoPage,
	"searchNearby": LocalSearchP.searchNearby,
	"searchInBounds": LocalSearchP.searchInBounds,
	"search": LocalSearchP.search,
	"clearResults": LocalSearchP.clearResults
});
function LocalResult(opts)
{
	this["keyword"] = opts.keyword || "";
	this._pageIndex = opts.pageIdx || 0;
	this._currentNumPois = opts.count || 0;
	this._numPois = opts.total || 0;
	this._numPages = TMath.ceil(opts.total / opts.pc);
	this["center"] = opts.center;
	this["radius"] = opts.radius;
	this["bounds"] = opts.bounds;
	this["city"] = opts.city;
	this["province"] = opts.province;
	this["viewport"] = opts.viewport;
	this["moreResultsUrl"] = opts.moreUrl;
	this._pois = opts.pois && opts.pois.slice(0) || [];
	this._cityList = opts.cityList && opts.cityList.slice(0);
	this["suggestions"] = opts.suggestions || []
}
baidu[Textend](LocalResult[Tprototype], {
	getPoi: function (i)
	{
		if (this._pois[i])
		{
			return this._pois[i]
		}
	}, getNumPois: function ()
	{
		return this._numPois
	}, getNumPages: function ()
	{
		return this._numPages
	}, getCurrentNumPois: function ()
	{
		return this._currentNumPois
	}, getPageIndex: function ()
	{
		return this._pageIndex
	}, getCityList: function ()
	{
		return this._cityList
	}, toString: function ()
	{
		return "LocalResult"
	}
});
var LocalResultP = LocalResult[Tprototype];
exportSymbol(LocalResultP, {
	"getPoi": LocalResultP.getPoi,
	"getCurrentNumPois": LocalResultP.getCurrentNumPois,
	"getNumPois": LocalResultP.getNumPois,
	"getNumPages": LocalResultP.getNumPages,
	"getPageIndex": LocalResultP.getPageIndex,
	"getCityList": LocalResultP.getCityList
});
function CustomSearch(localSearch)
{
	baidu.lang.Class.call(this);
	this.localSearch = localSearch;
	this.localSearch._curIndex = -1
}
baidu.lang.inherits(CustomSearch, baidu.lang.Class, "CustomSearch");
baidu[Textend](CustomSearch[Tprototype], {
	search: function (options)
	{
		this.localSearch._isMultiKey = false;
		if (!this._check(options))
		{
			return;
		}
		var me = this;
		this.localSearch._getIdByLoc(this.localSearch._loc, function (id)
		{
			options.region = id;
			var params = me._getParams(options);
			var userData = {params: params, options: options};
			me.searchRequest(params, userData)
		})
	}, _check: function ()
	{
		var flag = true;
		if (!AUTHENTIC_KEY)
		{
			this.localSearch._setStatus(BMAP_STATUS_INVALID_KEY);
			this.localSearch._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE);
			flag = false
		}
		return flag
	}, _getParams: function (options)
	{
		var params = {"region": options.region, "page_size": this.localSearch.getPageCapacity(), "ak": AUTHENTIC_KEY};
		if (options.page_index)
		{
			params["page_index"] = options.page_index;
		}
		if (options.keyword)
		{
			params["q"] = options.keyword;
		}
		if (options.bounds)
		{
			var sw = options.bounds.getSouthWest();
			var ne = options.bounds.getNorthEast();
			var bounds = sw["lat"] + "," + sw["lng"] + ";" + ne["lat"] + "," + ne["lng"];
			params["bounds"] = bounds
		}
		if (options.center && (options.center instanceof Point || options.center.point instanceof Point))
		{
			var center = null;
			if (options.center instanceof Point)
			{
				center = options.center;
			}
			else if (options.center.point instanceof Point)
			{
				center = options.center.point;
			}
			params["location"] = center["lat"] + "," + center["lng"]
		}
		if (typeof options.center == "string")
		{
			params["q"] = options.center + " " + options.keyword;
		}
		if (options.radius)
		{
			params["radius"] = options.radius;
		}
		if (options.customData && options.customData["databoxId"])
		{
			params["filter"] = "databox:" + options.customData["databoxId"];
		}
		return params
	}, searchRequest: function (params, userData)
	{
		var me = this;
		SearchRequestMgr.request(function (json, userData)
		{
			me._rawDataCbk(json, userData)
		}, params, userData, "geosearch/poi")
	}, _rawDataCbk: function (json, userData)
	{
		this.localSearch.clearResults();
		this.localSearch._ud = userData;
		if (json["status"] != 0)
		{
			this._results = new LocalResult({
				keyword: userData.options.keyword,
				pc: this.localSearch.getPageCapacity(),
				center: userData.options.center || "",
				radius: userData.options.radius || "",
				bounds: userData.options.bounds || "",
				moreUrl: ""
			});
			if (json["status"] == 5)
			{
				this.localSearch._setStatus(BMAP_STATUS_INVALID_KEY);
			}
			else
			{
				this.localSearch._setStatus(BMAP_STATUS_UNKNOWN_LOCATION);
			}
			this.localSearch._results = this._results;
			this.localSearch._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE, this._results);
			this.localSearch.renderList.dispatchEvent("render");
			return
		}
		this._processRaw(json, userData);
		this.localSearch.renderMap.dispatchEvent("render");
		this.localSearch.renderList.dispatchEvent("render");
		var center = userData.options.center;
		if (center && typeof center != "string" && !(center instanceof Point) && this.localSearch.getStatus() == BMAP_STATUS_SUCCESS)
		{
			this.localSearch.renderMap.addCenterPoi(center);
		}
		var viewData = {};
		viewData.points = this.localSearch._arrPoints;
		this.localSearch.renderMap.getBestViewport(viewData);
		var rs = this.localSearch._results;
		if (this.localSearch._opts.renderOptions.selectFirstResult && rs && rs.getNumPois() > 0)
		{
			var me = this;
			setTimeout(function ()
			{
				me.localSearch.select(0)
			}, 240)
		}
	}, _processRaw: function (json, userData)
	{
		var content = json["content"] || {}, me = this, pois = [], points = [], count = content[Tlength];
		for (var i = 0, size = json["size"]; i < size && content[i]; i++)
		{
			var cur = content[i];
			var point = new Point(cur["longitude"], cur["latitude"]);
			var poi = {
				"title": cur["name"],
				"uid": cur["uid"],
				"point": point,
				"url": "",
				"address": cur["addr"],
				"city": cur["city"],
				"province": cur["province"],
				"phoneNumber": cur["tel"],
				"postcode": cur["zip"],
				"type": cur["cla"]
			};
			pois.push(poi);
			points.push(point)
		}
		this.localSearch._arrPois = pois;
		this.localSearch._arrPoints = points;
		this._results = new LocalResult({
			keyword: userData.options.keyword,
			count: json["size"],
			total: json["total"],
			pageIdx: userData.params["page_index"],
			city: "",
			province: "",
			ccode: "",
			pois: pois,
			pc: this.localSearch.getPageCapacity(),
			center: userData.options.center,
			radius: userData.options.radius,
			bounds: userData.options.bounds,
			moreUrl: ""
		});
		if (json["total"] == 0)
		{
			this.localSearch._setStatus(BMAP_STATUS_UNKNOWN_LOCATION);
		}
		else
		{
			this.localSearch._setStatus(BMAP_STATUS_SUCCESS);
		}
		this.localSearch._results = this._results;
		this.localSearch._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE, this._results)
	}, gotoPage: function (pageNum)
	{
		var rs = this.localSearch._results;
		if (typeof pageNum == "number" && !isNaN(pageNum) && pageNum >= 0 && pageNum <= rs.getNumPages() - 1)
		{
			this.localSearch._ud.params["page_index"] = pageNum;
			this.searchRequest(this.localSearch._ud.params, this.localSearch._ud)
		}
		else
		{
			this.localSearch._setStatus(BMAP_STATUS_INVALID_REQUEST);
			this.localSearch._triggerCbk(BaseSearch.CBK_SEARCH_COMPLETE)
		}
	}
});
function RenderMap(localSearch)
{
	baidu.lang.Class.call(this);
	this.localSearch = localSearch;
	this.map = localSearch._opts.renderOptions.map;
	this._overlays = localSearch._overlays;
	this.initialize()
}
baidu.lang.inherits(RenderMap, baidu.lang.Class, "RenderMap");
baidu[Textend](RenderMap[Tprototype], {
	initialize: function ()
	{
		this[TaddEventListener]("render", this._render)
	}, _render: function ()
	{
		if (!this.map)
		{
			return;
		}
		var me = this, pois = this.localSearch._arrPois, points = [];
		for (var i = 0, len = pois[Tlength]; i < len; i++)
		{
			var poi = pois[i];
			points.push(poi["point"]);
			var mkr = this._addPoi(poi["point"], i, poi["title"]);
			if (!mkr)
			{
				continue;
			}
			poi["marker"] = mkr;
			(function ()
			{
				var index = i;
				mkr[TaddEventListener]("click", function ()
				{
					me.localSearch.select(index)
				})
			})();
			this._overlays.push(mkr)
		}
		this.localSearch._triggerCbk(BaseSearch.CBK_MARKERS_SET, pois)
	}, addCenterPoi: function (poi)
	{
		var center = poi;
		var me = this;
		if (center && typeof center != "string" && !(center instanceof Point))
		{
			var ctr = this.localSearch._centerMkr = APIPack.addCenterPoi(this.map, center["point"], center["title"]);
			ctr[TaddEventListener]("click", function ()
			{
				me.localSearch.select(-1);
				me.localSearch._curIndex = "c";
				var iw = me._createInfoWindowByPoi(poi);
				ctr.openInfoWindow(iw)
			})
		}
	}, _addPoi: function (pt, i, title)
	{
		if (this.localSearch._opts.pageCapacity <= LocalSearch.DEFAULT_PAGE_CAPACITY && !this.localSearch._isMultiKey)
		{
			return APIPack.addSearchPoi(this.map, pt, i, title);
		}
		else
		{
			return APIPack.addSearchInBoundsPoi(this.map, pt, title)
		}
	}, select: function (index)
	{
		if (this.map && index > -1 && this._overlays[index])
		{
			if (isMobile())
			{
				var marker = null;
				for (var j = 0, len = this._overlays[Tlength]; j < len; j++)
				{
					marker = this._overlays[j];
					if (index == j)
					{
						marker.setIcon(marker.icoActive);
					}
					else
					{
						marker.setIcon(marker.icoDefault);
					}
					marker["draw"]
				}
			}
			else
			{
				for (var j = 0, len = this._overlays[Tlength]; j < len; j++)
				{
					marker = this._overlays[j];
					marker.setTop(false)
				}
			}
			this.map.closeInfoWindow();
			var poi = this.localSearch._arrPois[index];
			if (!poi)
			{
				return;
			}
			var iw = this._createInfoWindowByPoi(poi);
			var mkr = this._overlays[index];
			mkr.setTop(true);
			mkr.openInfoWindow(iw)
		}
	}, _createInfoWindowByPoi: function (poi)
	{
		var iw = APIPack.createSearchInfoWnd({
			title: poi["title"],
			addr: poi["address"],
			tel: poi["phoneNumber"],
			url: poi["url"],
			poiType: poi["type"]
		});
		var me = this;
		iw[TaddEventListener]("close", function ()
		{
			me.localSearch.renderList.clearSelected()
		});
		iw[TaddEventListener]("open", function ()
		{
			me.localSearch._triggerCbk(BaseSearch.CBK_INFO_HTML_SET, poi, APIPack.getInfoWindowDom(me.map))
		});
		return iw
	}, getBestViewport: function (viewData)
	{
		var renderOptions = this.localSearch._opts.renderOptions;
		if (this.map)
		{
			if (viewData.points)
			{
				var pts = viewData.points;
				var preserve = !renderOptions.autoViewport, animation = !renderOptions.selectFirstResult && renderOptions.autoViewport, ret = this.map.getViewport(pts, {"margins": [30, 30, 30, 30]});
				if (!preserve)
				{
					this.map.setViewport(ret, {"enableAnimation": animation})
				}
			}
			else
			{
				viewData.level = SUtil.getBestLevel(viewData.level, this.map);
				if (renderOptions.autoViewport)
				{
					this.map.centerAndZoom(viewData.center, viewData.level)
				}
			}
		}
	}
});
function RenderList(localSearch)
{
	baidu.lang.Class.call(this);
	this.localSearch = localSearch;
	this.panel = localSearch._opts.renderOptions.panel;
	this.initialize()
}
baidu.lang.inherits(RenderList, baidu.lang.Class, "RenderList");
baidu[Textend](RenderList[Tprototype], {
	initialize: function ()
	{
		this[TaddEventListener]("render", this._render)
	}, _render: function ()
	{
		if (!this.panel)
		{
			return;
		}
		var container = create("div", {"style": "font:12px " + MapConfig.fontFamily + ";border:1px solid #999;"}), resultsContainer = create("div", {"style": "background:#fff"}), resultsList = create("ol", {"style": "list-style:none;padding:0;margin:0"}), status = this.localSearch.getStatus(), resultsControl = null;
		if (status == BMAP_STATUS_SUCCESS)
		{
			for (var i = 0, l = this.localSearch._arrPois[Tlength]; i < l; i++)
			{
				var item = this._createItem(i);
				resultsList[TappendChild](item)
			}
		}
		else if (status == BMAP_STATUS_CITY_LIST)
		{
			if (status == BMAP_STATUS_CITY_LIST && !this.localSearch._isMultiKey)
			{
				for (var i = 0, l = TMath.min(6, this.localSearch._results.getCityList()[Tlength]); i < l; i++)
				{
					var item = this._createCityItem(i);
					resultsList[TappendChild](item)
				}
			}
		}
		else
		{
			var tipTxt = "";
			switch (status)
			{
				case BMAP_STATUS_UNKNOWN_LOCATION:
					tipTxt = "\u62b1\u6b49\uff0c\u672a\u627e\u5230\u76f8\u5173\u5730\u70b9\u3002";
					break;
				case BMAP_STATUS_INVALID_KEY:
					tipTxt = "\u62b1\u6b49\uff0c\u60a8\u6240\u63d0\u4f9b\u7684key\u65e0\u6548\u3002";
					break
			}
			var item = create("li", {"style": "margin:2px 0;padding:0 5px 0 3px;overflow:hidden;line-height:17px"});
			item.innerHTML = tipTxt;
			resultsList[TappendChild](item)
		}
		resultsContainer[TappendChild](resultsList);
		container[TappendChild](resultsContainer);
		resultsControl = this._createResultsControl();
		container[TappendChild](resultsControl);
		this.panel[TappendChild](container);
		this.localSearch._triggerCbk(BaseSearch.CBK_RESULTS_HTML_SET, container)
	}, _createItem: function (index)
	{
		var r = this.localSearch._arrPois;
		if (!r || !r[index])
		{
			return;
		}
		var poi = r[index], item = create("li", {"style": "margin:2px 0;padding:0 5px 5px 0px;cursor:pointer;overflow:hidden;line-height:17px;*zoom:1;"});
		if (this.localSearch._curIndex > -1 && index == this.localSearch._curIndex)
		{
			item.style.backgroundColor = "#f0f0f0";
		}
		var offsetY = index == 0 ? "0px" : "-" + index * 25 + "px";
		if (this.localSearch._opts.pageCapacity > LocalSearch.DEFAULT_PAGE_CAPACITY || this.localSearch._isMultiKey)
		{
			offsetY = "-275px";
		}
		var htmls = ["<span style='background:url(" + API_URL + "images/markers.png) -23px " + offsetY + " no-repeat;width:19px;height:25px;cursor:pointer;float:left;*zoom:1;overflow:hidden;margin:2px 3px 0 5px;*margin-right:0px;display:inline;'>&nbsp;</span>"];
		var title, addr, kw;
		if (!this.localSearch._isMultiKey)
		{
			kw = this.localSearch._results["keyword"];
		}
		else
		{
			kw = this.localSearch._ud.userKw.join("|");
		}
		var regex = new TRegExp(kw, "ig");
		if (poi["title"])
		{
			title = poi["title"].replace(regex, "<b>$&</b>");
		}
		if (poi["type"] == BMAP_POI_TYPE_BUSSTOP)
		{
			title += "-\u516c\u4ea4\u8f66\u7ad9";
		}
		else if (poi["type"] == BMAP_POI_TYPE_SUBSTOP)
		{
			title += "-\u5730\u94c1\u7ad9";
		}
		htmls.push("<div style='zoom:1;overflow:hidden;padding:0 5px;'>");
		htmls.push("<div style='color:#00c;text-decoration:underline;height:20px;line-height:20px;font-size:12px;'>" + title + "</div>");
		if (poi["address"])
		{
			addr = poi["address"].replace(regex, "<b>$&</b>");
			htmls.push("<div style='padding:2px 0;line-height:18px;*zoom:1;overflow:hidden;'><b style='float:left;font-weight:bold;*zoom:1;overflow:hidden;padding-right:5px;*margin-right:-3px;'>\u5730\u5740:</b><span style='color:#666;display:block;zoom:1;overflow:hidden;'>" + addr + "</span></div>")
		}
		if (poi["phoneNumber"])
		{
			htmls.push("<div style='padding:2px 0;line-height:18px;*zoom:1;overflow:hidden;'><b style='float:left;font-weight:bold;*zoom:1;overflow:hidden;padding-right:5px;*margin-right:-3px;'>\u7535\u8bdd:</b><span style='color:#666;'>" + poi["phoneNumber"] + "</span></div>");
		}
		htmls.push("</div>");
		item.innerHTML = htmls.join("");
		var me = this;
		item.onclick = function ()
		{
			me.localSearch.select(index)
		};
		return item
	}, _createResultsControl: function ()
	{
		var me = this, resultsControl = create("div", {"style": "white-space:nowrap;text-align:right;background:#e5ecf9;margin-top:5px;padding:2px;overflow:hidden;zoom:1;"});
		if (!this.localSearch._isMultiKey && !this.localSearch._useCustomdata)
		{
			var moreUrl = create("a", {
				style: "color:#7777cc;float:right;",
				href: this.localSearch._results["moreResultsUrl"],
				target: "_blank",
				title: "\u5230\u767e\u5ea6\u5730\u56fe\u67e5\u770b\u66f4\u591a\u7ed3\u679c"
			});
			moreUrl.innerHTML = "\u66f4\u591a\u7ed3\u679c&#187;";
			resultsControl[TappendChild](moreUrl)
		}
		var paging = create("div", {"style": "float:left;margin-right:5px"});
		var maxRs = this.localSearch._getMaxResults();
		if (this.localSearch._arrPois[Tlength] > 0)
		{
			var pg = new Page(paging, function (page)
			{
				me.localSearch.gotoPage(page - 1)
			}, {pageCount: maxRs.getNumPages(), page: maxRs.getPageIndex() + 1, update: false});
		}
		resultsControl[TappendChild](paging);
		return resultsControl
	}, clearSelected: function ()
	{
		if (this.panel)
		{
			if (typeof this.localSearch._curIndex == "number" && this.localSearch._curIndex != -1 && this.panel.getElementsByTagName("li")[this.localSearch._curIndex])
			{
				this.panel.getElementsByTagName("li")[this.localSearch._curIndex].childNodes[1].style.backgroundColor = "";
			}
		}
		this.localSearch._curIndex = -1
	}, select: function (index)
	{
		if (this.panel)
		{
			var preIndex = this.localSearch._curIndex;
			if (typeof preIndex == "number" && preIndex != -1 && this.panel.getElementsByTagName("li")[preIndex])
			{
				this.panel.getElementsByTagName("li")[preIndex].childNodes[1].style.backgroundColor = "";
			}
			if (typeof index == "number" && index != -1 && this.panel.getElementsByTagName("li")[index])
			{
				this.panel.getElementsByTagName("li")[index].childNodes[1].style.backgroundColor = "#f0f0f0"
			}
		}
	}, _createCityItem: function (index)
	{
		var item = create("li", {"style": "margin:2px 0;padding:0 5px 0 3px;cursor:pointer;overflow:hidden;line-height:17px"});
		item._index = index;
		var clist = this.localSearch._results.getCityList();
		item.innerHTML = "<span style='color:#00c;text-decoration:underline'>" + clist[index]["city"] + "</span> <span style='color:#666'>(\u5171" + clist[index]["numResults"] + "\u6761\u7ed3\u679c)</span>";
		var localSearch = this.localSearch;
		var results = localSearch._results;
		item.onclick = function ()
		{
			localSearch.setLocation(results.getCityList()[index]["city"]);
			localSearch.search(results["keyword"])
		};
		return item
	}
});